package com.sec.bnjey.activity.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.sec.bnjey.R;

public class RbDialog extends Dialog {

	public static final String TITLE = "V Talk";
	/*
	 * Layoutrbcommon_custom_dialog
	 */
	private TextView tv_title;
	private TextView tv_contents;
	private Button btn1, btn2, btn3;
	String title, contents, btn1Title, btn2Title, btn3Title;

	private View.OnClickListener btnListender;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		WindowManager.LayoutParams lpWindow = new WindowManager.LayoutParams();
		lpWindow.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
		lpWindow.dimAmount = 0.8f;
		getWindow().setAttributes(lpWindow);

		setLayout();

	}

	public RbDialog(Context context, String title, String contents) {
		super(context, android.R.style.Theme_Translucent_NoTitleBar);
		this.title = title;
		this.contents = contents;
	}

	public RbDialog(Context context, String title, String contents,
			String btn1Title, View.OnClickListener listener) {
		super(context, android.R.style.Theme_Translucent_NoTitleBar);
		this.title = title;
		this.contents = contents;
		this.btnListender = listener;
		this.btn1Title = btn1Title;
	}

	public void initBtn(View.OnClickListener listener, String title1,
			String title2, String title3) {

		this.btnListender = listener;

		this.btn1Title = title1;
		this.btn2Title = title2;
		this.btn3Title = title3;

	}

	/*
	 * Layout
	 */
	private void setLayout() {
		setContentView(R.layout.rb_dialog);

		tv_title = (TextView) findViewById(R.id.tv_title);
		tv_title.setText(title);
		tv_contents = (TextView) findViewById(R.id.tv_content);
		tv_contents.setText(contents);

		btn1 = (Button) findViewById(R.id.btn1);
		btn2 = (Button) findViewById(R.id.btn2);
		btn3 = (Button) findViewById(R.id.btn3);

		if (btn1Title != null && btn1Title.length() > 0) {
			btn1.setText(btn1Title);
			btn1.setOnClickListener(this.btnListender);
		} else {
			btn1.setVisibility(View.GONE);
		}
		if (btn2Title != null && btn2Title.length() > 0) {
			btn2.setText(btn2Title);
			btn2.setOnClickListener(this.btnListender);
		} else {
			btn2.setVisibility(View.GONE);
		}
		if (btn3Title != null && btn3Title.length() > 0) {
			btn3.setText(btn3Title);
			btn3.setOnClickListener(this.btnListender);
		} else {
			btn3.setVisibility(View.GONE);
		}

	}

}
